#!/bin/sh


export APP_NAME=车牌识别系统
export runDir=`pwd`
export PYTHON_START_FILE=$runDir/manage.py
export PYTHON_HOME=
export PATH=$PYTHON_HOME/bin:$PATH
# date format
export dateFormat="date +%Y-%m-%d_%H:%M:%S"
echo  `$dateFormat` " $APP_NAME : $1"

export CFG_URL=http://localhost:80/cfg/sb.properties
# project config
START_OPTS=""
export MALLOC_ARENA_MAX=4

#启动方法
start(){
   mkdir -p log
   echo "启动$APP_NAME"
   # java $JAVA_OPTS -jar $PACKAGE_NAME $START_OPTS > /dev/null 2>&1 &
   nohup python3  $PYTHON_START_FILE runserver 0.0.0.0:8000 > log/all.log &
   date;sleep 5s;date
   ps -ef |grep `pwd`
   echo "启动完成，请查看日志"
}
#停止方法
stop(){
        echo "停止$APP_NAME"
        ps -ef|grep $PYTHON_START_FILE|grep -v "grep"|awk '{print $2}'|while read pid
        do
           kill $pid
           # kill -9 $pid
        done
        date;sleep 5s;date
        ps -ef |grep `pwd`
        echo "停止完成"
}

case "$1" in
start)
  start
  ;;
stop)
  stop
  ;;
restart)
  stop
  sleep 5
  start
  ;;
*)
  printf 'Usage: %s {start|stop|restart}\n' "$prog"
  exit 1
  ;;
esac
